<!DOCTYPE html>
<html>
  <head>
    <title><%= title %></title>
    <link rel='stylesheet' href='/stylesheets/style.css' />
  </head>
  <body>
    <h1><%= title %></h1>
    <input type="text" value="https://zh.libsolutions.domains/s/">
    <br>
    <input type="text" value="前端">
    <br>
    <input type="text" value="10">
    <br>
    <input type="text" value=".resItemBox">
    <br><br>
    <button onclick="send()">发送数据</button>
  </body>
  <script>
    const inputs = document.querySelectorAll('input')
    console.log(inputs)
    
    function send () {
        let data = {
            url: inputs[0].value + inputs[1].value + '?',
            maxPage: inputs[2].value,
            css: inputs[3].value
        }
        
        const xhr = new XMLHttpRequest
        xhr.open('post','/spider/spider')
        //- xhr.setHeader('Access-Control-Allow-Origin', '')
        xhr.setRequestHeader("Content-Type", "application/json")
        xhr.send(JSON.stringify(data))
        xhr.onreadystatechange = function () {
            if (xhr.readyState == 4) {
                console.log(xhr.response)
            }
        }
    }
  </script>
</html>
